{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "cdda40e9-3404-40d3-a94b-f77e80c98bed",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "116:2109020621\n",
      "115:2109020621\n",
      "1273:2170603107,2170603105\n",
      "实际参加测试的人数是： 3\n",
      "人均被测次数是：1.3\n"
     ]
    }
   ],
   "source": [
    "picd = {}\n",
    "numd = {}\n",
    "fi = open(\"dir_100.txt\",'r')\n",
    "for stulists in fi:\n",
    "    stulists = stulists.replace('\\n','').split('_') \n",
    "    if stulists [0] != '' :\n",
    "        lkey,lvalue = stulists[1][:-4],eval(stulists [0])\n",
    "        lval = []\n",
    "        for v in lvalue:\n",
    "            if v != '0':\n",
    "                lval.append(v)\n",
    "        if lval:\n",
    "            lv= ','.join(lval)\n",
    "            print(\"{}:{}\".format( lkey,lv))\n",
    "            picd[lkey] =lv\n",
    "fi.close()\n",
    "idd = {}\n",
    "for key in picd:\n",
    "    ids = picd[key].split(',') \n",
    "    for num in ids:\n",
    "        idd[num] = idd.get(num,0) +1\n",
    "s = 0\n",
    "for key in idd:\n",
    "    s += int(idd[key])\n",
    "count = len(idd)\n",
    "print(\"实际参加测试的人数是：\",count)\n",
    "print(\"人均被测次数是：{:.1f}\".format(s/count))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "326cafa8-7102-4c67-9866-e630ea5113f7",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
